Conversation
|
Back to draft, discussing with others first. And https://github.com/CodinGame/codingame-game-engine/blob/51a875604e5b736608666d49f6dde81ec191b033/runner/src/main/java/com/codingame/gameengine/runner/Agent.java#L124C21-L124C46
|
|
Back to review. DomiKo's changes affect another component (the runner), while this PR focuses on |
|
I believe it's already possible to do a timebank game using the Player.getLastExectionTimeMs() and gameManager.setTurnMaxTime before each player.execute to give each player their current timepool minus what they used last turn |
|
I like the three strike rule |
There is a hard limit of 30 seconds per game. The GameManager assumes that players always use the maximum possible time: Therefore you would exceed the 30 second limit without exceeded it in reality, that's a worst-case estimate. But I mostly care about the 3 strikes rule. If you don't want the time bank merged, I can live with that. |
In the recent contest we saw a high timeout rate, especially when the servers were busy on league opening, in the last hours of the contest and and the final rerun. This affected a lot of players even at the top of legend, so it seems to be a platform issue rather than players suddenly forgetting how to measure time. The contestant programs just get a random delay, sometimes 20 milliseconds long - and they lose the game because of it.



I understand that it's hard to prevent the server from doing any other tasks that affect program performance for contestants.
This commit is one suggestion to at least reduce the consequences of such a random delay by modifying the existing behaviour and introducing a new one.
Turn-based timing with 3-strikes rule
It lets each program run for an extra 50 milliseconds, but also checks if those extra 50ms were necessary. If they weren't, all is fine. Otherwise it counts as one strike, violating the time limit. If a bot exceeds the limit 3 times in the same match, it gets eliminated with a regular timeout exception. If even the additional 50ms don't help, the player can also get eliminated immediately.
Test link: https://www.codingame.com/ide/demo/1455013cb304fa9512c0f8525f73702f6e4a0c4
Timebank
Instead of setting a limit for each turn, the players get a time limit for the whole game. They can freely choose to use more time in one turn and less in another. This way a random delay won't be as punishing.
Test link: https://www.codingame.com/ide/demo/1455539e9339ee30ac7742e9204900bb7877948
note the changed input protocol, the remaining timebank is the first turn input, before powerSourceCount
Usage of those features
The game creator decides, if they want to use the classic per-turn way or the new timebank.
For the classic way no changes to the referee are needed, it will just work. For the timebank there has to be a call to
setTimebank, e.g.gameManager.setTimebank(10000);. When setting the timebank, it's not allowed to also callsetTurnMaxTime.